<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<script src="../js/vue.js"></script>

<body>
    <div id="app">
        <button @click='info'>info</button>
        <button @click="count">count mixin</button>
        <button @click="all">all</button>
    </div>
    <script>
        // 全局混入，影响每个vue实例对象
        Vue.mixin({
            methods: {
                all() {
                    console.log('all');
                }
            },
        })
        // 是一个对象，包含任何组件选项
        const mixin = {
            data() {
                return {
                    msg: "test mixin"
                }
            },
            created() {
                console.log('created');
                console.log(2)
            },
            methods: {
                count() {
                    console.log('test methods');
                }
            }
        }
        const vm = new Vue({
            el: '#app',
            created() {
                console.log(1)
            },
            methods: {
                info() {
                    console.log('info');
                }
            },
            // 混入（mixin）,可以混入一个对象
            mixins: [mixin]
        })
    </script>
</body>

</html>